import { Big } from "../core/Big";
import { Player } from "../core/Player";
import { Point, Terrain } from "../core/Point";
import Utils from "../GameUtils";

export enum 阵法 {
    未布置 = "未布置",
    迷雾森林 = "迷雾森林",
    佛法慈悲 = "佛法慈悲",
    九曲黄河 = "九曲黄河",
    地狱杀伐 = "地狱杀伐"
}

export class 灵阵 extends Big {
  
    isUsed = false
    type = 阵法.未布置
    arr_points = Array<Point>()

    turnStart(): void {
        if (!this.isUsed) {
            this.actionTime = 1
        }
        this.update()
    }

    die(murderer:Player, effect_point_id:string = null, is_show_effect:Boolean = true) {
        for (let p of this.arr_points) {
            p.removeMark(this)
        }
        super.die(murderer, effect_point_id, is_show_effect)
    }

    布阵(type: 阵法, point: Point) {
        this.isUsed = true
        this.arr_points = Utils.getArrPointsAround1And2(this.gameMgr, point)
        this.arr_points.push(point)
        for (let p of this.arr_points) {
            p.addMark(type, this)
        }
        this.actionTime = 0
    }

    terrainAdapt() {
        switch (this.point.terrain) {
            case Terrain.SHAN:
            case Terrain.SHUI:
                this.die(this.player)
        }
    }
}